package com.crk.controller;


import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.crk.entity.MDoctor;
import com.crk.service.IMDoctorService;
import com.crk.util.RestResult;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author com.crk
 * @since 2021-03-25
 */
@CrossOrigin
@RestController
@RequestMapping("/mid")
public class MDoctorController {

	@Autowired
	public IMDoctorService doctorService;
	
	@RequestMapping("/getDoc")
	public RestResult<MDoctor> getDoc(){
		List<MDoctor> list = doctorService.list();
		return RestResult.ok(list);
	}
	
	@RequestMapping("/addDoc")
	public RestResult<MDoctor> addDoc(MDoctor doc){
		doctorService.save(doc);
		return new RestResult<>();
	}
	
	@RequestMapping("/updateDoc")
	public RestResult<MDoctor> updateDoc(MDoctor doc){
		doctorService.updateById(doc);
		return new RestResult<>();
	}
	
	@RequestMapping("/deleteDoc")
	public RestResult<MDoctor> deleteDoc(Integer doctorIds){
		doctorService.removeByIds(Arrays.asList(doctorIds));
		return new RestResult<>();
	}
	
	
}

